/*===========================================================================+
 |   Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA    |
 |                         All rights reserved.                              |
 +===========================================================================+
 |  HISTORY                                                                  |
 +===========================================================================*/
package sza.oracle.apps.ap.oie.budget.webui;

import java.io.Serializable;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAKeyFlexBean;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;

/**
 * Controller for ...
 */
public class SzaOieMappingMaintainCO extends OAControllerImpl
{
  public static final String RCS_ID="$Header$";
  public static final boolean RCS_ID_RECORDED =
        VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

  /**
   * Layout and page setup logic for a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processRequest(pageContext, webBean);
      OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
     
      String mappingId = pageContext.getParameter("mappingId");
      if("".equals(mappingId) || mappingId==null){
          am.invokeMethod("createEmptyEntity");
      } else {
          Serializable[] parameters = {mappingId};
          am.invokeMethod("getMappingEntity",parameters);
      }
//      OAKeyFlexBean flexBean = (OAKeyFlexBean)webBean.findIndexedChildRecursive("FlexCCID");
//      flexBean.setStructureCode("SZA_ACC_FLEXFIELD"); 
//      flexBean.setCCIDAttributeName("CodeCombinationId"); 
//      flexBean.mergeSegmentsWithParent(pageContext);
  }

  /**
   * Procedure to handle form submissions for form elements in
   * a region.
   * @param pageContext the current OA page context
   * @param webBean the web bean corresponding to the region
   */
  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
    if(pageContext.getParameter("SaveBtn")!=null){
        am.getTransaction().commit();
        OAException message = new OAException("Done!",OAException.CONFIRMATION);
        pageContext.putDialogMessage(message);
    }
    if(pageContext.getParameter("ReturnBtn")!=null ){
        pageContext.forwardImmediately("OA.jsp?page=/sza/oracle/apps/ap/oie/budget/webui/SzaOiePaExpenseMappingPG"
                                       , null
                                       ,OAWebBeanConstants.KEEP_MENU_CONTEXT
                                       ,null
                                       ,null
                                       ,true
                                       ,OAWebBeanConstants.ADD_BREAD_CRUMB_NO); 
//        pageContext.forwardImmediately("OA.jsp?page=/sza/oracle/apps/ap/oie/budget/webui/SzaOiePaExpenseMappingPG",null,(byte)0, null, null, true, "Y");
    }
  }

}
